package org.example.service;

import io.github.resilience4j.circuitbreaker.annotation.CircuitBreaker;
import io.github.resilience4j.timelimiter.annotation.TimeLimiter;
import org.example.service.fallback.TestServiceFallback;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

@RequestMapping("/test")
@FeignClient(value = "eureka-client",fallback = TestServiceFallback.class)
//@TimeLimiter(name = "delay")
public interface TestService {
    @GetMapping("/hello")
    public String hello();

    @CircuitBreaker(name = "backendA",fallbackMethod = "fallback")
    @GetMapping("/world")
    public String world();

    @GetMapping("/timeout")
    public String timeout();

    default String fallback(Throwable throwable){
        return "断路器启动了";
    }
}
